package com.lagou.service.impl;/**
 * Created by IntelliJ IDEA.
 * User: Yangdx.
 * Date: 2020/7/26.
 * Time: 1:00.
 * Tags: Code, we are serious.
 */

import com.lagou.service.EmailService;
import com.lagou.util.MailUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Service;

/**
 * @author
 * @create 2020-07-26 1:00
 **/
@Service
@RefreshScope
public class EmailServiceImpl implements EmailService {
    @Value("${config.email.host}")
    private String mailHost;

    @Value("${config.email.sender.name}")
    private String mailFrom;

    @Value("${config.email.sender.password}")
    private String mailFromPassword;
    @Override
    public boolean sendEmail(String mailTo, String mailTitle, String message) {
        try {
            MailUtils.sendEmail(mailHost, mailFrom, mailFromPassword, mailTo, mailTitle, message);
            return true;
        } catch (Exception ex) {
            ex.printStackTrace();
            return false;
        }
    }
}
